<template>
	<view class="container" v-if="orderDetail.id">
		<view class="cell_title">菜品信息</view>
		<!-- start 列表 -->
		<view class="cell_content">
			<view class="celllist row">
				<view class="cell_img">
					<image :src="orderDetail.goods_info.image"></image>
				</view>
				<view class="cell_info">
					<view class="overflow-row cell_name">{{orderDetail.goods_info.name}}</view>
					<view class="overflow cell_fwb">{{orderDetail.goods_info.goods_naming.title}}</view>
					<view class="cell_price">
						<text>¥{{orderDetail.goods_info.goods_price}}</text>
						<text>x1</text>
					</view>
				</view>
			</view>
		</view>
		<!-- end -->
		<view class="cancellbutton" v-if="orderDetail.status==0" @click="confirmOrder">
			确认核销
		</view>
	</view>
</template>

<script>
	var app = getApp();
	import http from "../../../common/js/request.js";
	import common from "../../../common/js/function.js";
	export default {
		data() {
			return {
				orderDetail: []
			}
		},
		onLoad(options) {
			var that = this;
			http.post('api/store/order/CancelDishesList', {
				id: options.id
			}, res => {
				if (res.state == 1) {
					that.orderDetail = res.datas;
				} else {
					uni.showModal({
						title: '核销异常',
						content: res.datas,
						showCancel: false,
						success: res => {
							if (res.confirm) {
								uni.navigateBack();
							}
						},
					});
				}

			});
		},
		methods: {
			confirmOrder() {
				var that = this;
				uni.showModal({
					title: '确认操作',
					content: '您确认核销此订单吗？',
					success(e) {
						if (e.confirm) {
							http.post('api/store/order/CancelDishes', {
								id: that.orderDetail.id
							}, res => {
								if (res.state == 1) {
									that.orderDetail.status = 1;
									uni.showModal({
										title: '成功',
										content: '核销成功~',
										showCancel: false,
										success(e) {
											if (e.confirm) {
												uni.navigateBack();
											}
										}
									});
								} else {
									uni.showToast({
										title: res.datas,
										icon: 'none'
									});
								}
							});
						}
					}
				});

			}
		}
	}
</script>

<style>
	@import url("../../../common/css/cancellation.css");
</style>
